<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/***************************************************************************
 * 
 * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
 * 
 **************************************************************************/
 
 
 
/**
 * @todo 评论管理
 * @package controllers/admin 
 * @file comments.php
 * @author lihongliang01@baidu.com
 * @date 2014年12月6日 下午4:36:08
 * 
 *  
 **/
class Comments extends MY_ADMIN_Controller {
	
	public function __construct() {
		parent::__construct();
		$this->loadModel('Comments_model','Comments');
	
	}
	
	public function index() {
		$like = $this->_searchLike($this->Comments);
		$where = $this->_searchWhere($this->Comments);
		$map = array();
		if(!empty($like)) $map['like'] = $like;
		if(!empty($where)) $map['where'] = $where;
		$this->assign['result'] = $this->getPager($this->Comments,$map);
		$this->display();
	}
	
	/**
	 * 删除评论
	 * @param string $id
	 * @return bool
	 */
	public function remove($id=null){
		$redirect = getRedirect(base_url('admin/comments'));
		$id = $id>0?$id:intval($this->input->get('id',true));
		$res = $this->Comments->findByPk($id);
		if(empty($res)){
			return $this->showMessage('error_param',site_url('admin/comments'));
		}
		if($this->Comments->removeByPks($id) === true){
			$mes = 'mes_success';
			return $this->showMessage($mes,site_url('admin/comments'));
		}
		return $this->showMessage('failure',site_url('admin/comments'));
	}
}


/*End of file comments.php*/
/*Location comments.php */